﻿using System;
using System.Collections.Generic;
using System.Text;

namespace 设计模式
{
    class nba
    {
        public static void main() {
            player b = new forwards("巴蒂尔");
            b.attack();

            player m = new guards("麦克格雷迪");
            m.attack();

            player ym = new translator("姚明");
            ym.attack();

            Console.Read();
        }

    }

    class player {
        public string name;
        public player(string name) {
            this.name = name;
        }

        public virtual void attack(){}

        public virtual  void defense() { }



    }

    class forwards : player
    {
        public forwards(string name)
            : base(name)
        { 
        
        }

        public override void attack()
        {
            Console.WriteLine("前锋{0}进攻",name);

        }

        public override void defense()
        {
            Console.WriteLine("前锋{0}防守",name);
        }
    }

    class guards : player {
        public guards(string name)
            : base(name)
        { 
        
        }

        public override void attack()
        {
            Console.WriteLine("后卫{0}进攻",name);

        }

        public override void defense()
        {
            Console.WriteLine("后卫{0}防守",name);
        }
    }

    class foreign_center {
        public string name;

        public void 进攻() {
            Console.WriteLine("外籍中锋{0}进攻",name);
        }

        public void 防守() {
            Console.WriteLine("外籍中锋{0}防守",name);
        }
    }

    class translator : player {
        public translator(string name)
            : base(name)
        {
            fc.name = name;
        }

        private foreign_center fc = new foreign_center();
        


        public override void attack()
        {
            fc.进攻();

        }

        public override void defense()
        {
            fc.防守();
        }
    }



}
